<!doctype html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <title>KISSY - 全终端适配的 JS 类库</title>
  <meta name="viewport" content="width=device-width">
  <link href="http://fonts.googleapis.com/css?family=Droid+Sans|Lekton|Ubuntu+Mono:400,700" rel="stylesheet">
	<link rel="stylesheet" href="templates/assets/bootstrap.css">
	<link href="templates/assets/normalize.css" rel="stylesheet">
	<link href="templates/assets/kissy.css" rel="stylesheet">
	<link href="templates/assets/prettify.css" rel="stylesheet">
	<link href="templates/assets/forkit.css" rel="stylesheet">
	<script src="templates/assets/jquery.min.js"></script>
	<script src="templates/assets/script.js" type="text/javascript"></script>
	<script src="http://g.tbcdn.cn/trip/kissy/1.4.0/seed-min.js"></script>
	<script src="api/assets/highlight.pack.js"></script>
	<link href="api/assets/tomorrow-night-bright.css" rel=stylesheet />
	<link rel="shortcut icon" href="http://a.tbcdn.cn/s/kissy/favicon.ico">
</head>

<body class="">
    <nav id="sidebar">
    <header>
		<a href="index.html">
			<!--img src="http://gtms04.alicdn.com/tps/i4/T1ceiPFbpcXXcljp_h-200-89.png"-->
			<!--img src="templates/assets/img/logo_6.png"-->
			<!--img src="http://gtms04.alicdn.com/tps/i4/T14oa2FcNcXXaOySEh-180-104.png" alt="" /-->
			<!--img src="http://gtms01.alicdn.com/tps/i1/T1Amq1FaXgXXbXVSUh-180-127.png" alt="" /-->
			<img src="http://gtms02.alicdn.com/tps/i2/T1N0jTXXXjXXay7Rri-175-78.png" alt="" />
		</a>
	</header>
    <ul>
      <li class="nav-divider"><a href="index.html"><img src="templates/assets/img/icon-home.png">首页</a></li>
      <li class="nav-divider"><a href="why-kissy.html"><img src="templates/assets/img/icon-why.png">Why KISSY?</a></li>
      <li><a href="get-started.html"><img src="templates/assets/img/icon-getting-started.png">KISSY 1.4.x 教程大纲</a></li>
      <li class="nav-sub"><a href="module-map.html">核心模块列表</a></li>
      <li class="nav-sub"><a href="kmd.html">KISSY 模块规范 (KMD)</a></li>
      <li class="nav-sub"><a href="gbs.html">浏览器兼容基准(GBS)</a></li>
      <li class="nav-sub"><a href="http://cyj.me/jquery-kissy-rosetta/">jQuery KISSY 对比手册</a></li>
      <li class="nav-sub"><a href="http://gallery.kissyui.com/guide">KISSY 组件开发规范</a></li>
      <li class="nav-sub nav-divider"><a href="history.html">历史版本</a></li>
      <li><a href="">API Doc</a></li>
      <li><a href="http://demo.kissyui.com">Demos</a></li>
      <li class="nav-divider"><a href="http://gallery.kissyui.com">KISSY Gallery</a></li>
      <li><a href="tools.html">KISSY 项目构建工具</a></li>
      <li class="nav-sub"><a href="kmc.html">KS Module Compiler</a></li>
      <li class="nav-sub"><a href="http://abc.f2e.taobao.net">ABC</a></li>
      <li class="nav-sub nav-divider"><a href="clam.html">Clam</a></li>
      <li><a href="third-party-lib.html">第三方代码库</a></li>
      <li class="nav-sub"><a href="https://github.com/lorrylockie/tpap/wiki">面向第三方安全的 KISSY</a></li>
      <li class="nav-sub"><a href="http://www.builive.com/demo/index.php">BUI</a></li>
      <li class="nav-sub nav-divider"><a href="http://work.tmall.net/muidoc/build/">MUI</a></li>
      <li><a href="https://github.com/kissyteam/kissy/blob/master/CONTRIBUTING.md">为 KISSY Core 贡献代码</a></li>
      <li class="nav-sub"><a href="http://google-styleguide.googlecode.com/svn/trunk/htmlcssguide.xml">HTML/CSS编码规范</a></li>
      <li class="nav-sub nav-divider"><a href="http://docs.kissyui.com/source/tutorials/style-guide/google/javascriptguide.xml">JavaScript 编码规范</a></li>
	  <li><a href="upgrade.html"><img src="templates/assets/img/icon-documentation.png">1.3.x->1.4.0 升级指南</a></li>
	  <li><a href="faq.html"><img src="templates/assets/img/icon-faqs.png">FAQ</a></li>
      <li><a href="https://github.com/kissyteam/kissy"><img src="templates/assets/img/icon-github.png">GitHub</a></li>
	  <li><a href="core-team.html"><img src="templates/assets/img/icon-google-plus.png">KISSY 核心小组</a></li>
    </ul>
  </nav>

  <div id="content">
    <article>
      

	<style>
h3 {
    color:blue;
}
</style>

<h1>Uri</h1>
<p>uri 解析模块，用于处理URL。可以直接通过KISSY.Uri调用：</p>
<pre><code>var uri = new KISSY.Uri(&#39;http://url&#39;);
uri.do_somethine();// uri 执行相关的方法</code></pre>
<p>也可以通过沙箱来调用</p>
<pre><code>KISSY.use(&#39;uri&#39;,function(S,Uri){
    // 使用 Uri
});</code></pre>
<h3>clone()，克隆一个实例</h3>
<p><code>clone() =&gt; Uri</code>:：返回一个当前 uri 实例的克隆对象</p>
<pre><code>var one = new Uri(&#39;http://www.g.cn/x&#39;);
var two = one.clone() // 克隆一个新的Uri实例</code></pre>
<h3>resolve()</h3>
<p><code>resolve (other) =&gt; Uri</code>：合并解析出一个完整的URL，返回新的 uri 实例</p>
<pre><code>var one = new Uri(&#39;http://www.g.cn/x&#39;);
one.resolve(&#39;foo&#39;).toString() // =&gt; http://www.g.cn/foo
one.resolve(new Uri(&#39;?foo&#39;)).toString() // =&gt; http://www.g.cn/x?foo</code></pre>
<h3>getScheme() 得到协议部分</h3>
<p>用法：<code>getScheme () =&gt; String</code></p>
<pre><code>new Uri(&#39;http://www.g.cn/x&#39;).getScheme() // =&gt; http</code></pre>
<h3>setScheme() 设置协议部分</h3>
<p>设置 uri 实例的 scheme 部分</p>
<pre><code>new Uri(&#39;http://www.g.cn/x&#39;).setScheme(&#39;ftp&#39;).getScheme() // =&gt; ftp</code></pre>
<h3>getHostname()  得到hostname</h3>
<pre><code>new Uri(&#39;http://www.g.cn:8888/x&#39;).getHostname() // =&gt; www.g.cn</code></pre>
<h3>setHostname()  设置hostname</h3>
<pre><code>new Uri(&#39;http://www.g.cn:8888/x&#39;).setHostname(&#39;www.google.com&#39;).toString()
// =&gt; http://www.google.com:8888/x</code></pre>
<h3>getUserInfo()  得到用户信息</h3>
<p>获取当前 uri 实例的 user info</p>
<pre><code>new Uri(&#39;http://my:pass@www.g.cn:8888/x&#39;).getUserInfo() // =&gt; &#39;my:pass&#39;</code></pre>
<h3>setUserInfo()  设置用户信息</h3>
<p>设置当前 uri 实例的 user info</p>
<pre><code>new Uri(&#39;http://my:pass@www.g.cn:8888/x&#39;).setUserInfo(&#39;m:p&#39;).getUserInfo()
// =&gt; &#39;m:p&#39;</code></pre>
<h3>getPort() 获取当前 uri 实例的端口值</h3>
<pre><code>new Uri(&#39;http://my:pass@www.g.cn:8888/x&#39;).getPort()
// =&gt; &#39;8888&#39;</code></pre>
<h3>setPort()  设置当前 uri 实例的端口值</h3>
<pre><code>new Uri(&#39;http://my:pass@www.g.cn:8888/x&#39;).setPort(&#39;88&#39;).toString()
// =&gt; http://my:pass@www.g.cn:88/x</code></pre>
<h3>getPath()  获取当前 uri 实例的路径</h3>
<pre><code>new Uri(&#39;http://www.g.cn/x&#39;).getPath()
// =&gt; /x</code></pre>
<h3>setPath() 设置当前 uri 实例的路径</h3>
<pre><code>new Uri(&#39;http://www.g.cn/x&#39;).setPath(&#39;/y&#39;).toString()
// =&gt; http://www.g.cn/y</code></pre>
<h3>getQuery() 获取当前 uri 实例的查询参数实例</h3>
<pre><code>new Uri(&#39;http://www.g.cn/x?x=1&#39;).getQuery().get(&#39;x&#39;)
// =&gt; 1</code></pre>
<h3>setQuery()  设置当前 uri 实例的查询参数</h3>
<p>参数：query ({String|Uri.Query}) –     字符串或者Uri.Query实例</p>
<pre><code>new Uri(&#39;http://www.g.cn/x?x=1&#39;).setQuery(&#39;y=1&#39;).toString();
// =&gt; http://www.g.cn/x?y=1

new Uri(&#39;http://www.g.cn/x?x=1&#39;).setQuery(new Uri.Query(&#39;y=1&#39;)).toString();
// =&gt; http://www.g.cn/x?y=1</code></pre>
<h3>getFragment() 获取当前 uri 实例的 hash</h3>
<pre><code>new Uri(&#39;http://www.g.cn/x?x=1#y=2&#39;).getFragment() // =&gt; y=2</code></pre>
<h3>setFragment() 设置当前 uri 实例的 hash</h3>
<p>参数：hash ({String}) –  hash值</p>
<pre><code>new Uri(&#39;http://www.g.cn/x?x=1#y=2&#39;).setFragment(&#39;x=3&#39;).toString()
// =&gt; http://www.g.cn/x?x=1#x=3</code></pre>
<h3>isSameOriginAs()  验证同源</h3>
<p>验证当前 uri 实例和 other 是否是同源关系(hostname port scheme 相同)</p>
<pre><code>new Uri(&#39;http://www.g.cn/x?x=1#y=2&#39;)
.isSameOriginAs(new Uri(&#39;http://www.g.cn:88/x?x=1#y=2&#39;)) // =&gt; false</code></pre>
<h3>toString()  序列化当前 uri 实例的 hash</h3>
<p>参数：arr ({Boolean}) – 同 param() 同名参数</p>
<pre><code>new Uri(&#39;http://www.g.cn/x?x=1&amp;x=2&#39;).toString(false)
// =&gt; &#39;http://www.g.cn/x?x=1&amp;x=2&#39;

new Uri(&#39;http://www.g.cn/x?x=1&amp;x=2&#39;).toString(true)
// =&gt; &#39;http://www.g.cn/x?x%5b%5d=1&amp;x%5b%5d=2&#39;</code></pre>


<div id="disqus_thread"></div>
<script>
    if((window.location.hostname.indexOf("kissyui.com")!=-1 )&& window.localStorage.getItem("kissy-commment")!="0"){
    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
    var disqus_shortname = 'kissy-docs'; // required: replace example with your forum shortname

    // The following are highly recommended additional parameters. Remove the slashes in front to use.
     //var disqus_identifier = '/anim';
     //var disqus_url = window.location;

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function() {
        var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
        dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    })();
    }
</script>



      
  <style>
	.github-btn {
		border: 0 none;
		overflow: hidden;
		margin-top:4px;
	}
	footer {
		border-top:1px solid #e2e2e2;
		padding-top:20px;
		clear:both;
	}
	/* iPhone 及以下 */
	@media only screen and (max-width: 767px) {
		.github-link {
			display:none;
		}
	}
  </style>
  <footer>




	<div class="text-center">
		©2013 - 2033 KISSY UI LIBRARY
		<br /> <iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=kissyteam&amp;repo=kissy&amp;type=watch&amp;count=true" width="100" height="20" title="Star on GitHub"></iframe> 
	<iframe class="github-btn" src="http://ghbtns.com/github-btn.html?user=kissyteam&amp;repo=kissy&amp;type=fork&amp;count=true" width="102" height="20" title="Fork on GitHub"></iframe>
	</div>
  </footer>
    </article>
  </div>
  <a target="_blank" href="https://github.com/kissyteam/kissy" class="github-link"><img alt="Fork me on GitHub" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" style="position: absolute; top: 0; right: 0; border: 0; z-index: 50"></a>
  <script>
	var S = KISSY;
	(function(){
		S.use('node',function(S){
			S.all('code').each(function(node){
				var className = node.attr('class');
				if(/^lang-/.test(className)){
					var tc = className.replace(/^lang-/,'');
					node.replaceClass(className,tc);
				}
			});
			hljs.tabReplace = '    ';
			hljs.initHighlighting();
		});
	})();
	(function(){
		var h3s = document.getElementsByTagName('h3');
		for(var i = 0;i<h3s.length;i++){
			var str = S.trim(h3s[i].innerHTML);
			try{
				str = str.match(/\w+/)[0];
			}catch(e){
				continue;
			}
			h3s[i].innerHTML = '<a name="'+str+'"></a>' + h3s[i].innerHTML;
		}
	})();
  </script>
</body>
</html>
